<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="门窗系列">
              <a-input placeholder="请输入门窗系列" v-model="queryParam.windowSeries"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="门窗窗号">
              <a-input placeholder="请输入门窗窗号" v-model="queryParam.windowNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="仓库">
              <j-select-warehouse
                placeholder="请选择仓库"
                v-model="queryParam.warehouseId"
                @change="handleWarehouseChange"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="库位">
              <j-select-warehouse-location
                placeholder="请选择库位"
                v-model="queryParam.locationId"
                :warehouse-id="queryParam.warehouseId"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="库存状态">
              <j-dict-select-tag
                placeholder="请选择库存状态"
                v-model="queryParam.stockStatus"
                dictCode="finished_goods_stock_status"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="入库日期">
              <a-range-picker
                style="width: 100%"
                v-model="inboundDateRange"
                format="YYYY-MM-DD"
                @change="handleDateRangeChange"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="只显示有库存">
              <a-checkbox v-model="queryParam.onlyAvailable">只显示有库存</a-checkbox>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button style="margin-left: 8px" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('成品库存')">导出</a-button>
      <a-button type="primary" icon="reload" @click="loadData">刷新</a-button>
    </div>

    <!-- 层级数据表格 -->
    <div class="hierarchical-tables">
      <!-- 客户层级表格 -->
      <div v-for="customer in hierarchicalData" :key="customer.customerId" class="hierarchy-section">
        <a-card size="small" class="customer-card">
          <div slot="title" class="card-title-with-expand" @click="toggleCustomerExpand(customer.customerId)">
            <a-icon :type="customer.expanded ? 'caret-down' : 'caret-right'" class="expand-icon" />
            <span>客户信息 - {{ customer.customerName }}</span>
            <a-tag color="blue" style="margin-left: 8px"
              >{{ customer.orders ? customer.orders.length : 0 }}个订单</a-tag
            >
          </div>
          <a-table
            :columns="customerColumns"
            :dataSource="[customer]"
            :pagination="false"
            size="small"
            :showHeader="true"
            bordered
          >
            <template slot="customerType" slot-scope="text, record">
              <span>{{ record.customerTypeText || text }}</span>
            </template>
            <template slot="industry" slot-scope="text, record">
              <span>{{ record.industryText || text }}</span>
            </template>
          </a-table>

          <!-- 订单层级表格 -->
          <div v-if="customer.expanded">
            <div v-for="order in customer.orders" :key="order.orderId" class="order-section">
              <a-card size="small" class="order-card">
                <div slot="title" class="card-title-with-expand" @click="toggleOrderExpand(order.orderId)">
                  <a-icon :type="order.expanded ? 'caret-down' : 'caret-right'" class="expand-icon" />
                  <span>订单信息 - {{ order.orderNo }}</span>
                  <a-tag color="green" style="margin-left: 8px"
                    >{{ order.products ? order.products.length : 0 }}个产品</a-tag
                  >
                </div>
                <a-table
                  :columns="orderColumns"
                  :dataSource="[order]"
                  :pagination="false"
                  size="small"
                  :showHeader="true"
                  bordered
                >
                </a-table>

                <!-- 产品层级表格 -->
                <div v-if="order.expanded">
                  <div
                    v-for="(product, productIndex) in order.products"
                    :key="`${order.orderId}_${productIndex}`"
                    class="product-section"
                  >
                    <a-card size="small" class="product-card">
                      <div
                        slot="title"
                        class="card-title-with-expand"
                        @click="toggleProductExpand(`${order.orderId}_${productIndex}`)"
                      >
                        <a-icon :type="product.expanded ? 'caret-down' : 'caret-right'" class="expand-icon" />
                        <span>产品信息 - {{ product.windowNo }}</span>
                        <a-tag color="orange" style="margin-left: 8px"
                          >{{ product.locations ? product.locations.length : 0 }}个库位</a-tag
                        >
                      </div>
                      <a-table
                        :columns="productColumns"
                        :dataSource="[product]"
                        :pagination="false"
                        size="small"
                        :showHeader="true"
                        bordered
                      >
                        <template slot="productImage" slot-scope="text">
                          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
                          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width: 80px" />
                        </template>
                      </a-table>

                      <!-- 库存信息层级表格 -->
                      <div v-if="product.expanded">
                        <a-card :title="`库存信息`" size="small" class="inventory-card">
                          <a-table
                            :columns="inventoryColumns"
                            :dataSource="product.locations"
                            :pagination="false"
                            size="small"
                            :showHeader="true"
                            bordered
                          >
                            <template slot="locationStatus" slot-scope="text, record">
                              <span>{{ record.locationStatusText || text || '未知' }}</span>
                            </template>

                            <template slot="action" slot-scope="text, record">
                              <div class="action-buttons">
                                <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
                                <a-button type="link" size="small" @click="handleAdjust(record)">调整</a-button>
                                <a-dropdown>
                                  <a-button type="link" size="small"> 更多 <a-icon type="down" /> </a-button>
                                  <a-menu slot="overlay">
                                    <a-menu-item>
                                      <a @click="handleViewLogs(record)">变动记录</a>
                                    </a-menu-item>
                                    <a-menu-item>
                                      <a @click="handleReserve(record)">预留</a>
                                    </a-menu-item>
                                    <a-menu-item>
                                      <a @click="handleRelease(record)">释放</a>
                                    </a-menu-item>
                                  </a-menu>
                                </a-dropdown>
                              </div>
                            </template>
                          </a-table>
                        </a-card>
                      </div>
                    </a-card>
                  </div>
                </div>
              </a-card>
            </div>
          </div>
        </a-card>
      </div>
    </div>

    <!-- 分页 -->
    <a-pagination
      v-model="ipagination.current"
      :total="ipagination.total"
      :pageSize="ipagination.pageSize"
      :showSizeChanger="true"
      :showQuickJumper="true"
      :showTotal="(total, range) => `显示 ${range[0]}-${range[1]} 条，共 ${total} 条`"
      @change="handleTableChange"
      @showSizeChange="handleTableChange"
      style="margin-top: 20px; text-align: right"
    >
    </a-pagination>

    <!-- 模态框组件 -->
    <inventory-detail-modal ref="inventoryDetailModal" @ok="handleRefresh" />
    <inventory-adjust-modal ref="inventoryAdjustModal" @ok="handleRefresh" />
    <inventory-reserve-modal ref="inventoryReserveModal" @ok="handleRefresh" />
    <inventory-release-modal ref="inventoryReleaseModal" @ok="handleRefresh" />
    <inventory-statistics-modal ref="inventoryStatisticsModal" />
    <inventory-log-modal ref="inventoryLogModal" />
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'
import JSelectWarehouse from '@/components/jeecgbiz/JSelectWarehouse'
import JSelectWarehouseLocation from '@/components/jeecgbiz/JSelectWarehouseLocation'
import InventoryDetailModal from './modules/InventoryDetailModal'
import InventoryAdjustModal from './modules/InventoryAdjustModal'
import InventoryStatisticsModal from './modules/InventoryStatisticsModal'
import InventoryLogModal from './modules/InventoryLogModal'
import InventoryReserveModal from './modules/InventoryReserveModal'
import InventoryReleaseModal from './modules/InventoryReleaseModal'
// 成品库存不需要低库存预警功能，按订单生产模式

export default {
  name: 'InventoryList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    JSelectWarehouse,
    JSelectWarehouseLocation,
    InventoryDetailModal,
    InventoryAdjustModal,
    InventoryStatisticsModal,
    InventoryLogModal,
    InventoryReserveModal,
    InventoryReleaseModal,
  },
  data() {
    return {
      description: '成品库存管理 - 按订单组织的库存管理，支持订单级库存追踪和精确发货控制',
      // 表头
      columns: [
        {
          title: '层级信息',
          dataIndex: 'hierarchyInfo',
          key: 'hierarchyInfo',
          width: 350,
          scopedSlots: { customRender: 'hierarchyInfo' },
        },
        {
          title: '产品信息',
          align: 'center',
          dataIndex: 'productInfo',
          width: 200,
          scopedSlots: { customRender: 'productInfo' },
        },
        {
          title: '仓储信息',
          align: 'center',
          dataIndex: 'storageInfo',
          width: 200,
          scopedSlots: { customRender: 'storageInfo' },
        },
        {
          title: '库存状态',
          align: 'center',
          dataIndex: 'stockStatus',
          width: 100,
          customRender: function (text, record) {
            if (record.type !== 'location') return ''
            if (text === 0) return '正常'
            if (text === 1) return '预留'
            if (text === 2) return '冻结'
            if (text === 3) return '缺货'
            return text
          },
        },
        {
          title: '总数量',
          align: 'center',
          dataIndex: 'totalQuantity',
          width: 100,
        },
        {
          title: '其他信息',
          align: 'center',
          dataIndex: 'otherInfo',
          width: 150,
          scopedSlots: { customRender: 'otherInfo' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      customerColumns: [
        {
          title: '客户名称',
          dataIndex: 'customerName',
          key: 'customerName',
          width: 150,
          align: 'center',
        },
        {
          title: '客户联系人',
          dataIndex: 'contactPerson',
          key: 'contactPerson',
          width: 200,
          align: 'center',
        },
        {
          title: '客户类型',
          dataIndex: 'customerType',
          key: 'customerType',
          width: 100,
          align: 'center',
          scopedSlots: { customRender: 'customerType' },
        },
        {
          title: '行业',
          dataIndex: 'industry',
          key: 'industry',
          width: 120,
          align: 'center',
          scopedSlots: { customRender: 'industry' },
        },
        {
          title: '联系电话',
          dataIndex: 'contactPhone',
          key: 'contactPhone',
          width: 120,
          align: 'center',
        },
        {
          title: '总库存',
          dataIndex: 'availableQuantity',
          key: 'availableQuantity',
          width: 80,
          align: 'center',
        },
      ],
      orderColumns: [
        {
          title: '订单编号',
          dataIndex: 'orderNo',
          key: 'orderNo',
          width: 150,
          align: 'center',
        },
        {
          title: '订单日期',
          dataIndex: 'orderDate',
          key: 'orderDate',
          width: 120,
          align: 'center',
        },
        {
          title: '交货日期',
          dataIndex: 'deliveryDate',
          key: 'deliveryDate',
          width: 120,
          align: 'center',
        },
        {
          title: '总库存',
          dataIndex: 'availableQuantity',
          key: 'availableQuantity',
          width: 80,
          align: 'center',
        },
      ],
      productColumns: [
        {
          title: '窗号',
          dataIndex: 'windowNo',
          key: 'windowNo',
          width: 120,
          align: 'center',
        },
        {
          title: '系列',
          dataIndex: 'windowSeries',
          key: 'windowSeries',
          width: 100,
          align: 'center',
        },
        {
          title: '颜色',
          dataIndex: 'windowColor',
          key: 'windowColor',
          width: 100,
          align: 'center',
        },
        {
          title: '产品图片',
          dataIndex: 'productImage',
          key: 'productImage',
          width: 100,
          align: 'center',
          scopedSlots: { customRender: 'productImage' },
        },
        {
          title: '总库存',
          dataIndex: 'totalQuantity',
          key: 'totalQuantity',
          width: 80,
          align: 'center',
        },
      ],
      inventoryColumns: [
        {
          title: '仓库',
          dataIndex: 'warehouseName',
          key: 'warehouseName',
          width: 220,
          align: 'center',
        },
        {
          title: '库位',
          dataIndex: 'locationName',
          key: 'locationName',
          width: 220,
          align: 'center',
        },
        {
          title: '库存数量',
          dataIndex: 'totalQuantity',
          key: 'totalQuantity',
          width: 120,
          align: 'center',
          customRender: (text) => text || 0,
        },
        {
          title: '库位状态',
          dataIndex: 'locationStatus',
          key: 'locationStatus',
          width: 120,
          align: 'center',
          scopedSlots: { customRender: 'locationStatus' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          key: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/wms/finished-goods/inventory/queryHierarchicalForWeb',
        delete: '/wms/finished-goods/inventory/delete',
        deleteBatch: '/wms/finished-goods/inventory/deleteBatch',
        exportXlsUrl: '/wms/finished-goods/inventory/exportXls',
        importExcelUrl: 'wms/finished-goods/inventory/importExcel',
      },
      hierarchicalData: [], // 分层级数据
      dictOptions: {},
      inboundDateRange: [],
      selectedRowKeys: [],
      rowSelection: {
        selectedRowKeys: [],
        onChange: this.onSelectChange,
        onSelect: this.onSelect,
        onSelectAll: this.onSelectAll,
      },
    }
  },
  created() {
    this.loadData(1)
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    // 重写loadData方法以支持层级数据
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      // 加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams() // 查询条件
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          // 处理分层级数据
          this.hierarchicalData = res.result.records || res.result
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },

    // 切换客户展开/折叠状态
    toggleCustomerExpand(customerId) {
      const customer = this.hierarchicalData.find((c) => c.customerId === customerId)
      if (customer) {
        this.$set(customer, 'expanded', !customer.expanded)
      }
    },

    // 切换订单展开/折叠状态
    toggleOrderExpand(orderId) {
      this.hierarchicalData.forEach((customer) => {
        if (customer.orders) {
          const order = customer.orders.find((o) => o.orderId === orderId)
          if (order) {
            this.$set(order, 'expanded', !order.expanded)
          }
        }
      })
    },

    // 切换产品展开/折叠状态
    toggleProductExpand(productKey) {
      const [orderId, productIndex] = productKey.split('_')
      this.hierarchicalData.forEach((customer) => {
        if (customer.orders) {
          const order = customer.orders.find((o) => o.orderId === orderId)
          if (order && order.products && order.products[productIndex]) {
            this.$set(order.products[productIndex], 'expanded', !order.products[productIndex].expanded)
          }
        }
      })
    },

    // 处理层级数据，展开为表格行
    processHierarchicalData(hierarchicalData) {
      const flatData = []

      hierarchicalData.forEach((customer) => {
        // 添加客户行
        flatData.push({
          key: `customer_${customer.customerId}`,
          type: 'customer',
          level: 0,
          customerName: customer.customerName,
          customerCode: customer.customerCode,
          contactPerson: customer.contactPerson,
          contactPhone: customer.contactPhone,
          totalQuantity: customer.totalQuantity,
          availableQuantity: customer.availableQuantity,
          reservedQuantity: customer.reservedQuantity,
          orderCount: customer.orders ? customer.orders.length : 0,
          expanded: false,
          children: customer.orders || [],
        })
      })

      return flatData
    },

    // 展开/折叠行
    toggleExpand(record) {
      const index = this.dataSource.findIndex((item) => item.key === record.key)
      if (index === -1) return

      this.dataSource[index].expanded = !this.dataSource[index].expanded

      if (this.dataSource[index].expanded) {
        // 展开：插入子级数据
        this.insertChildRows(record, index + 1)
      } else {
        // 折叠：移除子级数据
        this.removeChildRows(record.key)
      }
    },

    // 插入子级行数据
    insertChildRows(parentRecord, insertIndex) {
      const childRows = []

      if (parentRecord.type === 'customer' && parentRecord.children) {
        parentRecord.children.forEach((order) => {
          childRows.push({
            key: `order_${order.orderId}`,
            type: 'order',
            level: 1,
            parentKey: parentRecord.key,
            orderNo: order.orderNo,
            orderDate: order.orderDate,
            projectName: order.projectName,
            totalQuantity: order.totalQuantity,
            availableQuantity: order.availableQuantity,
            reservedQuantity: order.reservedQuantity,
            productCount: order.products ? order.products.length : 0,
            expanded: false,
            children: order.products || [],
          })
        })
      } else if (parentRecord.type === 'order' && parentRecord.children) {
        parentRecord.children.forEach((product) => {
          const productCode = `${product.windowSeries}-${product.windowNo}-${product.windowColor || ''}`
          childRows.push({
            key: `product_${parentRecord.key}_${productCode}`,
            type: 'product',
            level: 2,
            parentKey: parentRecord.key,
            windowSeries: product.windowSeries,
            windowNo: product.windowNo,
            windowColor: product.windowColor,
            productCode: productCode,
            totalQuantity: product.totalQuantity,
            availableQuantity: product.availableQuantity,
            reservedQuantity: product.reservedQuantity,
            locationCount: product.locations ? product.locations.length : 0,
            expanded: false,
            children: product.locations || [],
          })
        })
      } else if (parentRecord.type === 'product' && parentRecord.children) {
        parentRecord.children.forEach((location) => {
          childRows.push({
            key: `location_${location.inventoryId}`,
            type: 'location',
            level: 3,
            parentKey: parentRecord.key,
            warehouseName: location.warehouseName,
            locationName: location.locationName,
            locationCode: location.locationCode,
            batchNo: location.batchNo,
            stockStatus: location.stockStatus,
            totalQuantity: location.totalQuantity,
            availableQuantity: location.availableQuantity,
            reservedQuantity: location.reservedQuantity,
            inboundDate: location.inboundDate,
            id: location.inventoryId,
          })
        })
      }

      // 插入子级行
      this.dataSource.splice(insertIndex, 0, ...childRows)
    },

    // 移除子级行数据
    removeChildRows(parentKey) {
      const toRemove = []

      // 找到所有需要移除的子级行
      this.dataSource.forEach((item, index) => {
        if (item.parentKey === parentKey) {
          toRemove.push(index)
          // 递归移除子级的子级
          this.removeChildRows(item.key)
        }
      })

      // 从后往前移除，避免索引变化
      toRemove.reverse().forEach((index) => {
        this.dataSource.splice(index, 1)
      })
    },

    initDictConfig() {
      // 初始化字典配置
    },
    getSuperFieldList() {
      // 获取字段列表
    },
    handleWarehouseChange() {
      // 仓库变更时清空库位选择
      this.queryParam.locationId = ''
    },
    handleDateRangeChange(dates) {
      if (dates && dates.length === 2) {
        this.queryParam.inboundStartDate = dates[0]
        this.queryParam.inboundEndDate = dates[1]
      } else {
        this.queryParam.inboundStartDate = null
        this.queryParam.inboundEndDate = null
      }
    },
    handleRefresh() {
      this.loadData(1)
    },
    handleDetail(record) {
      this.$refs.inventoryDetailModal.show(record)
    },
    handleAdjust(record) {
      this.$refs.inventoryAdjustModal.show(record)
    },
    handleViewLogs(record) {
      this.$refs.inventoryLogModal.show(record.id)
    },
    handleReserve(record) {
      this.$refs.inventoryReserveModal.show(record, 'reserve')
    },
    handleRelease(record) {
      this.$refs.inventoryReleaseModal.show(record)
    },
    handleStatistics() {
      this.$refs.inventoryStatisticsModal.show()
    },
    batchAdjust() {
      this.$message.info('批量调整功能开发中...')
    },
    batchReserve() {
      this.$message.info('批量预留功能开发中...')
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.rowSelection.selectedRowKeys = selectedRowKeys
    },
    onSelect(record, selected, selectedRows) {
      console.log(record, selected, selectedRows)
    },
    onSelectAll(selected, selectedRows, changeRows) {
      console.log(selected, selectedRows, changeRows)
    },
  },
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';

.hierarchical-tables {
  .hierarchy-section {
    margin-bottom: 20px;

    .customer-card {
      border: 2px solid #1890ff;
      border-radius: 8px;

      .order-section {
        margin: 16px 0;
        margin-left: 20px;

        .order-card {
          border: 1px solid #52c41a;
          border-radius: 6px;

          .product-section {
            margin: 12px 0;
            margin-left: 20px;

            .product-card {
              border: 1px solid #faad14;
              border-radius: 4px;

              .inventory-card {
                margin-top: 12px;
                border: 1px solid #f5222d;
                border-radius: 4px;

                .inventory-table {
                  .ant-table-tbody > tr:hover > td {
                    background-color: #e6f7ff;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

.ant-card-head-title {
  font-weight: 600;
}

.ant-table-small {
  .ant-table-thead > tr > th {
    background-color: #fafafa;
    font-weight: 600;
  }
}

.card-title-with-expand {
  cursor: pointer;
  display: flex;
  align-items: center;
  user-select: none;

  &:hover {
    color: #1890ff;
  }

  .expand-icon {
    margin-right: 8px;
    transition: transform 0.2s;
  }
}

/* 层级显示样式 */
.hierarchy-customer {
  font-weight: bold;
  color: #1890ff;
}

.hierarchy-order {
  font-weight: 500;
  color: #52c41a;
}

.hierarchy-product {
  color: #fa8c16;
}

.hierarchy-location {
  color: #722ed1;
}

/* 层级缩进样式 */
.ant-table-tbody > tr > td {
  border-bottom: 1px solid #f0f0f0;
}

.ant-table-tbody > tr[data-row-key*='customer'] > td {
  background-color: #f6ffed;
  font-weight: bold;
}

.ant-table-tbody > tr[data-row-key*='order'] > td {
  background-color: #f9f9f9;
}

.ant-table-tbody > tr[data-row-key*='product'] > td {
  background-color: #fff7e6;
}

.ant-table-tbody > tr[data-row-key*='location'] > td {
  background-color: #f9f0ff;
}

.action-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}

.action-buttons .ant-btn-link {
  padding: 0 6px;
  height: 24px;
  line-height: 22px;
  font-size: 12px;
  min-width: auto;
}

.action-buttons .ant-btn-link:hover {
  background-color: #f5f5f5;
}
</style>
